#include "fastrpc/rpc.hpp"
#include "hello.pb.h"

using namespace fastrpc::log;
using namespace fastrpc::io;
using namespace fastrpc::net;
using namespace fastrpc::async;
using namespace fastrpc;
using namespace fastrpc::rpc;
auto client() -> Task<void> {
    auto res = co_await RpcClient::GetInstance("127.0.0.1", 10000);
    if (!res) {
        console.error("{}", res.error().message());
        co_return;
    }
    auto    client = std::move(res.value());
    Request request;
    request.set_str("hello world");
    auto result = co_await client.call<Request, Response>("123456789",
                                                          "rpc_serivce.hello",
                                                          std::ref(request));
    std::cout << "response : " << result.str() << std::endl;
}
int main() {
    SET_LOG_LEVEL(fastrpc::log::LogLevel::Debug);
    runtime::CurrentThreadBuilder::default_create().block_on(client());
}
